package com.anxin.act.task.cmd;

import org.activiti.engine.impl.interceptor.Command;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.entity.HistoricTaskInstanceEntity;

/**
 * @author: liuxiangyu
 * @date: 2020/5/18 13:57
 */
public class UpdateHiTaskReasonCmd implements Command<Void> {
    protected String taskId;
    protected String deleteReason;

    public UpdateHiTaskReasonCmd(String taskId, String deleteReason) {
        this.taskId = taskId;
        this.deleteReason = deleteReason;
    }
    @Override
    public Void execute(CommandContext commandContext) {
        HistoricTaskInstanceEntity historicTaskInstance = commandContext
                .getDbSqlSession().selectById(HistoricTaskInstanceEntity.class,taskId);
        if (historicTaskInstance != null) {
            historicTaskInstance.markEnded(deleteReason);
        }
        return null;
    }
}
